import { createRouter, createWebHistory } from 'vue-router'
import UserHomeView from '../views/user/UserHomeView.vue'
import Home from "@/views/merchant/Home.vue";
import HomeView from '../views/merchant/HomeView.vue';
import AdminHomeView from "@/views/admin/AdminHomeView.vue";

const routes = [
  {
    path: '/',
    name: 'user-home',
    component: UserHomeView,
    redirect: '/product',
    children: [
      { path: 'product', component: () => import('../views/user/product/ProductView.vue') },
      { path: 'order', component: () => import('../views/user/order/OrderView.vue') },
      { path: 'cart', component: () => import('../views/user/cart/CartView.vue') },
      { path: 'person', component: () => import('../views/user/person/PersonView.vue') },
      { path: 'product/detail', component: () => import('../views/user/product/DetailView.vue') },
      { path: 'live', component: () => import('../views/user/live/RoomLiving.vue') },
      { path: 'live/de', component: () => import('../views/user/live/LiveDetail.vue') },
      { path: 'live/li', component: () => import('../views/user/live/live直播.vue') },
      { path: 'support', component: () => import('../views/user/support/SupportingFarmersView.vue') },
      { path: 'search/product', component: () => import('../views/user/product/SearchProductView.vue') },
      // 一下是助农模块路由
      {
        path: '/PolicyPage',
        name: 'PolicyPage',
        component: () => import('../views/user/support/policy/PolicyPage.vue')
      },
      {
        path: '/ProductPage',
        name: 'ProductPage',
        component: () => import('../views/user/support/product/ProductPage.vue')
      },
      {
        path: '/StoryPage',
        name: 'StoryPage',
        component: () => import('../views/user/support/story/StoryPage.vue')
      },
      {
        path: '/policy-detail/:id',
        name: 'PolicyDetail',
        component: () => import('../views/user/support/policy/PolicyDetail.vue')
      },
      {
        path: '/story-detail/:id',
        name: 'StoryDetail',
        component: () => import('../views/user/support/story/StoryDetail.vue')
      },
      {
        path: '/product-detail/:id',
        name: 'ProductDetail',
        component: () => import('../views/user/support/product/ProductDetail.vue')
      },
    ]
  },
  {
    path: '/',
    name: 'admin-home',
    component: AdminHomeView,
    redirect:'/users',
    children:[
      {
        path: '/users',
        component: () => import('../views/admin/AllUsers.vue'),
        meta: { title: '查看所有用户' }
      },
      {
        path: 'edit-user',
        component: () => import('../views/admin/no_use/EditUser.vue'),
        meta: { title: '增加用户信息' }
      },
      {
        path: 'all-stores',
        component: () => import('../views/admin/AllStores.vue'),
        meta: { title: '查看所有店铺' }
      },
      {
        path: 'pending-stores',
        component: () => import('../views/admin/no_use/PendingStores.vue'),
        meta: { title: '查看需审核店铺' }
      },
      {
        path: 'approve-store',
        component: () => import('../views/admin/ApproveStore.vue'),
        meta: { title: '审核店铺功能' }
      },
      {
        path: 'stories-farmers',
        component: () => import('../views/admin/StoriesFarmers.vue'),
        meta: { title: '助农故事' }
      },
      {
        path: 'agricultural-policy',
        component: () => import('../views/admin/AgriculturalPolicy.vue'),
        meta: { title: '助农政策' }
      },
      {
        path: 'agricultural-products',
        component: () => import('../views/admin/AgriculturalProducts.vue'),
        meta: { title: '助农商品' }
      }
    ]
  },



  {
    path: '/',
    name: 'merchant-home',
    component: HomeView,
    redirect: '/home',
    children: [
      { path: '/home', component: Home },
      { path: '/merchant', component: () => import('../views/merchant/MerchantView.vue') },
      { path: '/adminHome', component: () => import('../views/admin/AdminHomeView.vue') },
      { path: '/add', component: () => import('../views/merchant/ProductAddView.vue') },
      { path: '/userHome', component: () => import('../views/user/UserHomeView.vue') },
      { path: '/delete1', component: () => import('../views/merchant/MerchantDeleteView.vue') },
      { path: '/revise', component: () => import('../views/merchant/MerchantReviseView.vue') },
      { path: '/list', component: () => import('../views/merchant/MerchantListView.vue') },
      { path: '/productList', component: () => import('../views/merchant/ProductList.vue') },
      { path: '/delete2', component: () => import('../views/merchant/ProductDeleteView.vue') },
      { path: '/update', component: () => import('../views/merchant/ProductUpdateView.vue') },

      { path: '/live', component: () => import('../views/merchant/Live.vue') },
      { path: '/order', component: () => import('../views/merchant/Order.vue') }
    ]
  },

  { path: '/login', component: () => import('../views/LoginView.vue') }, // 注意补全.vue扩展名
  { path: '/reg', component: () => import('../views/RegView.vue') },




]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})



export default router